/******************************************************************************
Copyright:
2009 Jens Collin (jens.collin@dinomin.com)

This file is part of Envox Decompiler.

Envox Decompiler is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Envox Decompiler is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with KitchenOS.  If not, see <http://www.gnu.org/licenses/>.

******************************************************************************/
using System;

namespace EnvoxDecompiler
{
	/// <summary>
	/// Summary description for BlockOutput.
	/// </summary>
	public class BlockOutput
	{
		// the output type, Next, ConfDestroyed, etc.
		private Block.OUTPUT _outputType;
		// Id number of the block that this output should connect to.
		long _connectsToBlockId;
		// output number
		int _id;
		/// <summary>
		/// Error id number (studio handledErrors constants)
		/// </summary>
		int errorId_;


		/// <summary>
		/// Get the error id set for this block-output.
		/// </summary>
		/// <returns>Error id for block output</returns>
		public int GetErrorNumber()
		{
			return errorId_;
		}


        /// <summary>
        /// Constructs a blockOutput that leads to another block, uninitialized.
        /// </summary>
        /// <param name="outputType">type of block output</param>
        /// <param name="errorId">Error number for studio fo this type of
        /// output.</param>
        public BlockOutput(Block.OUTPUT outputType, int errorId)
        {
            _connectsToBlockId = -1;
            _outputType = outputType;
            errorId_ = errorId;
        }


		/// <summary>
		/// Constructs a blockOutput that leads to another block.
		/// </summary>
		/// <param name="outputType">type of block output</param>
		/// <param name="connectsToBlockId">block to which this connection
		/// leads.</param>
		/// <param name="errorId">Error number for studio fo this type of
		/// output.</param>
		public BlockOutput(Block.OUTPUT outputType, long connectsToBlockId, int errorId)
		{
			_connectsToBlockId = connectsToBlockId;
			_outputType = outputType;
			errorId_ = errorId;
		}

		/// <summary>
		/// Return the output type of this output type, such as Next, Failed, etc..
		/// </summary>
		/// <returns></returns>
		public Block.OUTPUT GetOutputType()
		{
			return _outputType;
		}


		/// <summary>
		/// Get the block to which this output points to.
		/// </summary>
		/// <returns></returns>
		public long GetConnectsTo()
		{
			return _connectsToBlockId;
		}

		/// <summary>
		/// Set output id number, just an sequence id number for this block-exit.
		/// </summary>
		/// <param name="id"></param>
		public void SetId(int id)
		{
			_id = id;
		}

		/// <summary>
		/// Get the output id number. sequence number.
		/// </summary>
		/// <returns></returns>
		public int GetId()
		{
			return _id;
		}

		/// <summary>
		/// Setter for output type. Used in changer methods for example in the
		/// TimeSwitch block.
		/// </summary>
		/// <param name="outputType"></param>
		public void SetOutputType(Block.OUTPUT outputType)
		{
			_outputType = outputType;
		}


	}
}
